package edu.uci.ics.ai.maze.models;

import java.util.Collections;
import java.util.List;

/**
 * Model for storing results from a {@link SearchAlgorithm} run.
 *
 * @author dpurpura
 */
public class SearchResult {

  private final SearchAlgorithm algorithm;
  private final List<Vertex> path;
  private final long searchTime;
  private final double pathCost;

  public SearchResult(SearchAlgorithm algorithm, List<Vertex> path,
          long searchTime, double pathCost) {
    this.algorithm = algorithm;
    this.path = Collections.unmodifiableList(path);
    this.searchTime = searchTime;
    this.pathCost = pathCost;
  }

  /**
   * @return the algorithm
   */
  public SearchAlgorithm getAlgorithm() {
    return algorithm;
  }

  /**
   * Returns the return path for the current algorithm.
   *
   * @return the return path
   */
  public List<Vertex> getPath() {
    return path;
  }

  /**
   * Returns the number of vertices in the return path.
   *
   * @return the number of vertices
   */
  public int getPointsInPath() {
    return getPath().size();
  }

  /**
   * Returns the approximate length of time to search in nanoseconds.
   *
   * @see System#nanoTime()
   * @return the length of time in nanoseconds
   */
  public long getSearchTime() {
    return searchTime;
  }

  /**
   * @return the pathCost
   */
  public double getPathCost() {
    return pathCost;
  }

}
